Casper CBC: Python PoC
features
A validator receives a message, then if at least one of justification of the message is not justified, the message is marked as pending
(otherwise the message is marked as justified)
A validator receives a message, then if it is included in the justification of other pending message B, B is justified and unmarked as pending
If B is included in the justification other pending message C, the same thing is made to C
A validator receives a message and justified, then if the message's sequence number (added by sender) is larger than existing latest messages fro m the same sender, the message is added to latest message.
View
class AbstractView: state used by global and individual validator
justified_messages
pending_messages
num_missing_dependencies
dependents_of_message
latest_messages
def add_messages(self, showed_messages):
def receive_justified_message(self, message):
get justified message and _add_to_latest_messages, add_justified_remove_pending, and _update_protocol_specific_view
def receive_pending_message(self, message, missing_message_hashes):
add pending message
add dependents
def get_newly_justified_messages(self, message):
def _add_justified_remove_pending(self, message):
def _missing_messages_in_justification(self, message):
return hashes of the justification of the message which are not included in self.justified_messages
class BlockchainView(AbstractView): global blockchain state
def estimate(self):
return block selected by fork_choice
def update_safe_estimates(self, validator_set):
update last_finalized_block if the block selected by fork_choice is safe by using CliqueOracle
Message
class Message(object):
class Block(Message):
is_valid_estimate
return isinstance(estimate, Block) or estimate is None
conflicts_with
Returns true if self is not in the prev blocks of other_message
Validator
class Validator(object):
name, weight, validator_set, view
def receive_messages(self, messages):
add message to view
def estimate(self):
return estimate(set of messages) selected by fork_choice
def my_latest_message(self):
return self.view.latest_messagesself def update_safe_estimates(self):
return self.view.update_safe_estimates(self.validator_set)
def make_new_message(self):
add new message to view and return it
def justification(self):
return the headers of latest message seen from other validators
def _next_sequence_number(self):
Oracle
WIP
Questions
Block is defined as Message instead of Concensus Value?
memo
message
sender
estimate
justification
sequence_number
estimate
by estimator
justification
hashes of latest messages from each validator
estimator
fork choice